import Request from '@/utils/requset.js'
let request = new Request().http

function removeStr(obj) {
  if(obj) {
    let removePropertyOfNull=function(obj){
      Object.keys(obj).forEach(item=>{
        if(!obj[item])  delete obj[item]
      })
      return obj;
    }
    removePropertyOfNull(obj)
  }
  return obj?obj:''
}

// 微信登录
const userWxLogin = (params) => {
	return request({
	    url: "/nailAppUser/wxLogin",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 通过id查询用户(我的)
const getMyInfo = (params) => {
	return request({
	    url: "/nailAppUser/queryById",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 查询客服微信列表
const queryCustomWeixinInfo = (params) => {
	return request({
	    url: "/nailCustomerServiceWeixin/queryCustomWeixinInfo",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 通过可用状态查询尺码列表（指甲类型对应大小）
const getNailSize = (params) => {
	return request({
	    url: "/nailSize/querySize",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 通过可用状态查询甲片形状列表（指甲类型）
const getNailShape = (params) => {
	return request({
	    url: "/nailShape/queryShape",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 查询用户积分流水
const getScoreQueryByUserId = (params) => {
	return request({
	    url: "/nailScore/queryByUserId",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 前端标签列表查询
const getQuerylist = (params) => {
	return request({
	    url: "/nailTag/querylist",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 用户收藏图库中所有主题元素图案（可用标签检索）我的图库
const getMySubjectElements = (params) => {
	return request({
	    url: "/nailSubject/mySubjectElements",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 根据Id查询图库效果和元素 我的图库(效果图详情)
const getQuerySubjectInfo = (params) => {
	return request({
	    url: "/nailSubject/querySubjectInfo",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 商品列表
const getGoodsList = (params) => {
	return request({
	    url: "/nailGoodsInfo/queryList",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 通过id查询某件商品
const getGoodsInfo= (params) => {
	return request({
	    url: "/nailGoodsInfo/queryById",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 购物车减掉商品
const getAddCart= (params) => {
	return request({
	    url: "/nailGoodsInfo/subCart",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 用户添加地址
const addUserAddr= (params) => {
	return request({
	    url: "/nailUserAddr/add",
	    method: "POSt",
	    data: removeStr(params),
	})
}

// 通过用户id查询地址
const getUserAddr= (params) => {
	return request({
	    url: "/nailUserAddr/queryByUserId",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 用户收藏图库
const userCollectSubject= (params) => {
	return request({
	    url: "/nailSubject/collectSubject",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 秀自己
const createUserShow= (params) => {
	return request({
	    url: "/nailShow/createUserShow",
	    method: "POST",
	    data: removeStr(params),
	})
}

// 提交反馈
const nailCustomerService= (params) => {
	return request({
	    // url: "/nailCustomerService/add",
		// url: '/nailCustomerService/createCustomeQuestion',
		url: '/nailCustomerService/add',
	    method: "POST",
	    data: removeStr(params),
	})
}

// 短信发送接口
const sendSms= (params) => {
	return request({
	    url: "/nailSms/sendSms",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 验证短信码
const verfiyCode= (params) => {
	return request({
	    url: "/nailSms/verfiyCode",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 图库列表
const querySubjectList= (params) => {
	return request({
	    url: "/nailSubject/querySubjectList",
		// url: "/nailSubject/querySubjectInfo",
	    method: "GET",
	    params: removeStr(params),
	})
}

// 支付
const getHasSubject= (params) => {
	return request({
	    url: "/nailSubject/hasSubject",
	    method: "GET",
	    params: removeStr(params),
	})
}

export {
	userWxLogin,
	getMyInfo,
	queryCustomWeixinInfo,
	getNailShape,
	getNailSize,
	getScoreQueryByUserId,
	getQuerylist,
	getMySubjectElements,
	getGoodsList,
	getGoodsInfo,
	getAddCart,
	addUserAddr,
	getUserAddr,
	getQuerySubjectInfo,
	userCollectSubject,
	createUserShow,
	sendSms,
	verfiyCode,
	querySubjectList,
	nailCustomerService,
	getHasSubject
}